package org.jawa.model;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import java.io.Serializable;

@Entity
@Table(name = "inquire")
public class Inquire extends BaseObject implements Serializable {
	
	private static final long serialVersionUID = -1925461067526969501L;
	private Long id;
	private Product product;
	private User user;
	private String inquirecontent;
	private String reply;
	private Date inquiredate;
	private Date replydate;
	private Character status;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PRODUCTID")
	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "USERID")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "INQUIRECONTENT", length = 500)
	public String getInquirecontent() {
		return this.inquirecontent;
	}

	public void setInquirecontent(String inquirecontent) {
		this.inquirecontent = inquirecontent;
	}

	@Column(name = "REPLY", length = 500)
	public String getReply() {
		return this.reply;
	}

	public void setReply(String reply) {
		this.reply = reply;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "INQUIREDATE", length = 0)
	public Date getInquiredate() {
		return this.inquiredate;
	}

	public void setInquiredate(Date inquiredate) {
		this.inquiredate = inquiredate;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "REPLYDATE", length = 0)
	public Date getReplydate() {
		return this.replydate;
	}

	public void setReplydate(Date replydate) {
		this.replydate = replydate;
	}

	@Column(name = "STATUS", length = 1)
	public Character getStatus() {
		return this.status;
	}

	public void setStatus(Character status) {
		this.status = status;
	}

	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		Inquire pojo = (Inquire) o;

		if (product != null ? !product.equals(pojo.product)
				: pojo.product != null)
			return false;
		if (user != null ? !user.equals(pojo.user) : pojo.user != null)
			return false;
		if (inquirecontent != null ? !inquirecontent
				.equals(pojo.inquirecontent) : pojo.inquirecontent != null)
			return false;
		if (reply != null ? !reply.equals(pojo.reply) : pojo.reply != null)
			return false;
		if (inquiredate != null ? !inquiredate.equals(pojo.inquiredate)
				: pojo.inquiredate != null)
			return false;
		if (replydate != null ? !replydate.equals(pojo.replydate)
				: pojo.replydate != null)
			return false;
		if (status != null ? !status.equals(pojo.status) : pojo.status != null)
			return false;

		return true;
	}

	public int hashCode() {
		int result = 0;
		result = (product != null ? product.hashCode() : 0);
		result = 31 * result + (user != null ? user.hashCode() : 0);
		result = 31 * result
				+ (inquirecontent != null ? inquirecontent.hashCode() : 0);
		result = 31 * result + (reply != null ? reply.hashCode() : 0);
		result = 31 * result
				+ (inquiredate != null ? inquiredate.hashCode() : 0);
		result = 31 * result + (replydate != null ? replydate.hashCode() : 0);
		result = 31 * result + (status != null ? status.hashCode() : 0);

		return result;
	}

	public String toString() {
		StringBuffer sb = new StringBuffer(getClass().getSimpleName());

		sb.append(" [");
		sb.append("id").append("='").append(getId()).append("', ");
		sb.append("product").append("='").append(getProduct()).append("', ");
		sb.append("user").append("='").append(getUser()).append("', ");
		sb.append("inquirecontent").append("='").append(getInquirecontent())
				.append("', ");
		sb.append("reply").append("='").append(getReply()).append("', ");
		sb.append("inquiredate").append("='").append(getInquiredate()).append(
				"', ");
		sb.append("replydate").append("='").append(getReplydate())
				.append("', ");
		sb.append("status").append("='").append(getStatus()).append("'");
		sb.append("]");

		return sb.toString();
	}

}
